<?php
/**
 * Created by PhpStorm.
 * User: tc-net modify by tom_xia
 * Date: 2018/3/14 0014
 * Time: 10:29
 */
require_once dirname(__DIR__) . "/common.php";
use app\cls\tom\Queue;
use app\cls\tom\Response;
use app\cls\tom\SysResource;
use app\cls\tom\Tools;
use app\cls\tom\Visitor;
$host = @parse_url(isset($_SERVER['HTTP_REFERER'])?$_SERVER['HTTP_REFERER']:"",PHP_URL_HOST);
$visitor = new Visitor();
$visitorInfo = $visitor->getVisitorId();
$d['xm'] = isset($_GET['xm']) ? trim($_GET['xm']) : 'host';  //项目
$d['op'] = isset($_GET['op']) ? trim($_GET['op']) : 'pv';   //pv 还是share
$d['wz'] = isset($_GET['wz']) ? trim($_GET['wz']) : '';        //位置
$d['pt'] = isset($_GET['pt']) ? trim($_GET['pt']) : 'h5';     //平台 h5 web
$d['uniqueid'] = isset($_GET['uniqueid']) && $_GET["uniqueid"] != "undefined" ? trim($_GET['uniqueid']) : "";
$d['other'] = isset($_GET['other']) ? trim($_GET['other']) : '';
$d['uid'] = $visitorInfo[1];
$d['ip'] = explode(",",Tools::get_client_ip())[0];
$d['time'] = date("Y-m-d H:i:s");

if($d['xm']&&$d['uid']){
    $redis = SysResource::getRedis();
    $queue = new Queue($redis,REDIS_PREFIX."PV");
    $r = $queue->push(json_encode($d),rand(1,100));
    Response::output(0,"ok",["vir_ID"=>$visitorInfo[0]]);
}else{
    Response::output(-1,"fail",["vir_ID"=>$visitorInfo[0]]);
}

